package com.easylinkin.linkappapi.jglplant.entity;


import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Objects;

/**
 * 鸡公岭-专家研究领域(JglExpertResearchArea)表实体类
 *
 * @author makejava
 * @since 2022-02-22 11:44:20
 */
@SuppressWarnings("serial")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class JglExpertResearchArea extends Model<JglExpertResearchArea> {
    //专家id
    private Integer expertId;
    //纲
    private String type1;
    //科
    private String type2;
    //属
    private String type3;
    //种
    private String type4;

    public boolean notAllTypeEmpty() {
        return ObjectUtils.isNotEmpty(getType1())
                || ObjectUtils.isNotEmpty(getType2())
                || ObjectUtils.isNotEmpty(getType3())
                || ObjectUtils.isNotEmpty(getType4());
    }

    public String allTypeToString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.type1).append(",").append(this.type2).append(",").append(this.type3).append(",").append(this.type4);
        return sb.toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        JglExpertResearchArea that = (JglExpertResearchArea) o;
        return Objects.equals(expertId, that.expertId) && Objects.equals(type1, that.type1) && Objects.equals(type2, that.type2) && Objects.equals(type3, that.type3) && Objects.equals(type4, that.type4);
    }

    @Override
    public int hashCode() {
        return Objects.hash(expertId, type1, type2, type3, type4);
    }

    public JglExpertResearchArea() {
    }

    public JglExpertResearchArea(Integer expertId, String type1, String type2, String type3, String type4) {
        this.expertId = expertId;
        this.type1 = type1;
        this.type2 = type2;
        this.type3 = type3;
        this.type4 = type4;
    }

    public static void main(String[] args) {
        System.out.println(new JglExpertResearchArea(null, null, null, null, null).hashCode());
        System.out.println(new JglExpertResearchArea(null, null, null, null, null).allTypeToString());
        System.out.println(new JglExpertResearchArea(0, "1", null, null, "2").hashCode());
        System.out.println(new JglExpertResearchArea(0, "1", null, null, "2").hashCode());
    }
}

